/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wave;

import ast.*;
import base.Utilities;
import base.Wave;
import base.WaveEnvironment;
/**
 *
 * @author THAI
 */
public class ASTFunctionCallExecution  extends WaveExecution {
    public ASTFunctionCallExecution(WaveHeadParser parser, WaveEnvironment waveEnv){
        super(parser, waveEnv);
    }

    public void execute(ASTFunctionCall funcall, String tail){
        Utilities.WPPrint("Execute Function Call");
        //Utilities.WPPrint(super.toString());
        SimpleNode left = (SimpleNode)funcall.jjtGetChild(0);
        //SimpleNode right = (SimpleNode)funcall.jjtGetChild(1);
        String v;
        String t;
        t = left.toString();
        t = t.substring(t.indexOf(":")+2);        
        v = waveEnv.getFrontalTable().get(t).toString();
        v = v.substring(1, v.length()-1);
        while (v.charAt(0)=='{') v = v.substring(1, v.length()-1);
        if (!tail.equals(""))
            v += "." +tail;
        Wave newWave = new Wave(v, new WaveEnvironment(waveEnv));
        waveQueue.incomingFront(newWave);
    }
}
